<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@taglib prefix="s" uri="/struts-tags"%>

  <head>
    <base href="<%=basePath%>">
    <title>修改账户密码</title>
    <script type='text/javascript' src='dwr/interface/userdwr.js'></script>
    <script type="text/javascript" src="<s:url value="/js/jquery-1.4.2.min.js"/>"></script>
 <script type='text/javascript' src='js/jquery.validate.min.js'></script>
 <script type='text/javascript' src='js/common.js'></script>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<link href="images/css.css"  rel="stylesheet" type="text/css" />
<link href="manage/manage.css" rel="stylesheet" type="text/css">
	<style type="text/css">
<!--
a:link {
	text-decoration: none;
}
a:visited {
	text-decoration: none;
}
a:hover {
	text-decoration: none;
}
a:active {
	text-decoration: none;
}
.STYLE13 {color: #A3A3A3}
.STYLE15 {color: #F18910}


-->
</style>
<script type="text/javascript">
  var passwordFlag =false;
  
  function checkValid(){
  	  var userMobile = $.trim($("#userMobile").val());  //会话中获取手机号
  	  var oldPwd = $.trim($("#oldPassword").val());  //旧密码
	  var newPWd = $.trim($("#resetPassword").val());//重置密码
	  var comfirmPwd = $.trim($("#confirmationPassword").val());
//	  alert("userMobile="+userMobile);
	  var pwdDb = $.trim($("#pwdDb").val());//DB密码
	  
	   if(oldPwd == "" || oldPwd.length <= 0){
			$("#oldPwdSpan").html("请输入旧密码.");
			$("#oldPassword").focus();
			return false;
		}else{
			//alert("pwd=="+pwdDb);
			if(pwdDb != oldPwd){
				$("#oldPwdSpan").html("输入的旧密码有误.");
				$("#oldPassword").select();
				return false;
			}
			$("#oldPwdSpan").html("");

		}
		
		
	  //  checkUserPwd(userMobile,oldPwd);
	  
	    if(newPWd == "" || newPWd.length <= 0){
			$("#newPWdSpan").html("&nbsp;请输入重置密码.");
			$("#resetPassword").focus();
			return false;
		}else{
			if(newPWd.length < 6 || newPWd.length > 16){
				$("#newPWdSpan").html("");
				$("#newPWdSpan").html("&nbsp;输入的重置密码有误.");
				$("#resetPassword").select();
				return false;
			}else{
				$("#newPWdSpan").html("");
			}
		
			$("#newPWdSpan").html("");
		}
		if(comfirmPwd == "" || comfirmPwd.length <= 0){
			$("#comfirmPwdSpan").html("请输入确认密码.");
			$("#confirmationPassword").focus();
			return false;
		}else{
			if(comfirmPwd.length < 6 || comfirmPwd.length > 16){
				$("#comfirmPwdSpan").html("输入的确认密码有误.");
				$("#confirmationPassword").select();
				return false;
			}else{
				$("#comfirmPwdSpan").html("");
			}
			
			$("#comfirmPwdSpan").html("");
		}
		
		//------------以下是效验密码的正确性
/*		if(!passwordFlag){
			$("#oldPwdSpan").html("输入的旧密码有误.");
			$("#oldPassword").select();
			return false;
		}else
		{
			passwordFlag = false;
			$("#oldPwdSpan").html("");
		}*/
		
		//效验输入的重置密码和旧密码是否一致
		if(newPWd == oldPwd){
			$("#newPWdSpan").html("输入的重置密码不能和旧密码一致.");
			$("#resetPassword").select();
			return false;
		}else{
			$("#newPWdSpan").html("");
		}
		//效验输入的重置密码和确认密码是否一致
		if(newPWd != comfirmPwd){
			$("#comfirmPwdSpan").html("输入的确认密码和重置密码不一致.");
			$("#confirmationPassword").select();
			 return false;	
		}else{
			$("#comfirmPwdSpan").html("");
		}
		
	  return true;
  }
  //表单提交
  function modifySubmit()
  {
  		if(!checkValid()){
  			return false;
  		}else{
  			document.modPwd.submit();
  		}
  }
  
function isZiMu_Num(str) {
	//var voidChar = /[@#\$%\^&\*]+/g;
	var voidChar = /^[A-Za-z0-9_]+$/g;
	
	return voidChar.test(str);
}
  
  //获取后台生成的密码
function checkUserPwd(userMobile,usrPwd){
	dwr.engine.setAsync(false);   //ajax設置同步调用
	userdwr.checkUPwd(userMobile,usrPwd,function(data) {
	//	alert("data=>>>>>"+data);
		if(data){
			passwordFlag = true; //表示密码存在
		//	alert("密码存在=");
		}else{
			passwordFlag = false;
			//alert("else>>user_name="+user_name);
		}
		//alert("checkUPwd >passwordFlag= "+passwordFlag);
	});
}

function mysubmit() {
	var oldPwd = $.trim($("#oldPassword").val());  //旧密码
	var newPWd = $.trim($("#resetPassword").val());//重置密码
	var newPWd2 = $.trim($("#confirmationPassword").val());//重置密码
	if (oldPwd == "") {
		alert("请输入旧密码");
		return;
	}
	if (newPWd == "") {
		alert("请输入新密码");
		return;
	}
	if (newPWd2 == "") {
		alert("请输入确认新密码");
		return;
	}
	if (newPWd!=newPWd2) {
		alert("两次输入的新密码不一致，请重新输入");
		return;
	}
	$("#pwdForm").submit();
}
  
</script>

</head>
  
<body>

<body style="margin:0px; text-align:center;font-size:12px;" bgcolor="#F1F1F1" >
<div id="top">
 	<!-- 头部-->
 	<%@include file="mainTop.jsp"%>
</div>
<div id="top2"></div>

<!-- 中间-->
<div id="main1">
<!-- 左边-->
 <%@include file="mainLeft.jsp"%>
 <div class="mainr2">
  <s:form action="loginAction!modifyManagePwd.action" name="modPwd" id="pwdForm" method="post">
	<table width="789" height="539" border="0" cellpadding="0" cellspacing="0" bgcolor="#F1F1F1">
  <tr>
    <td height="500" align="left" valign="top" bgcolor="#FFFFFF" style="border:1px solid #C5C5C5; padding:1px ;">
    <table width="100%" height="32" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="1%" height="32" background="images/sp_bg.jpg">&nbsp;</td>
        <td width="3%" align="center" background="images/sp_bg.jpg" style="border-bottom:1px solid #C5C5C5;"><img src="images/dian.jpg" width="10" height="16" /></td>
        <td width="95%" align="left" background="images/sp_bg.jpg" style="border-bottom:1px solid #C5C5C5;"><span class="STYLE3">修改密码</span></td>
        <td width="1%" background="images/sp_bg.jpg">&nbsp;</td>
      </tr>
    </table>
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr> <%-- 20120131 操作成功提示信息 --%>
          <td height="48" align="center"><span style="color:blue;"><s:property value="ActionError"/></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
        </tr>
      </table>

      <input type="hidden" name="pwdDb" id="pwdDb" value='<s:property value="#session.userObject.password" />' />
      <table width="610" height="150" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td width="151" align="right">旧密码：</td>
          <td width="459" align="left">
          <input name="oldPassword" id="oldPassword" type="password" size="20" maxlength="16" style="border:1px solid #DBDBDB; height:20px;"  />
          &nbsp;<font color="red">*&nbsp;<span style="color:red" id="oldPwdSpan"></span></font>
          </td>
        </tr>
        <tr>
          <td align="right">重置密码：</td>
          <td align="left">
          <input name="password" id="resetPassword" type="password" size="20" maxlength="16" style="border:1px solid #DBDBDB; height:20px;"  />
            &nbsp;<font color="red">*</font>6-16位字符(字母、数字、符号)&nbsp;<span style="color:red" id="newPWdSpan"></span>
          </td>
        </tr>
        <tr>
          <td align="right">确认密码：</td>
          <td align="left">
          	<input name="confirmationPwd" id="confirmationPassword" type="password" size="20" maxlength="16" style="border:1px solid #DBDBDB; height:20px;"  />
          	&nbsp;<font color="red">*&nbsp;<span style="color:red" id="comfirmPwdSpan"></span></font>
          </td>
        </tr>
        <tr>
          <td height="51">&nbsp;</td>
          <td align="left">
          <img src="images/bc.jpg" onclick="mysubmit();" style="cursor:hand" name="submitMod" id="modPwdSub" width="92" height="24" />
          </td>
        </tr>
        <tr>
        	<td></td>
        	<s:if test="hasErrors()">
        	<td style="color: red;">
        		<s:actionerror/>
        	</td>
        	</s:if>
			<s:if test="hasActionMessages()">
				<td style="color: green;">
					<s:actionmessage/>
				</td>
			</s:if>        	
        </tr>
      </table>
      </td>
  </tr>
</table>    

</s:form>
 </div>
</div>

</body>
</html>
